package com.czxy.test01;

import com.czxy.config.MyBatisConfig;
import com.czxy.config.SpringConfig;
import com.czxy.domain.User;
import com.czxy.service.AccountService;
import com.czxy.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.util.List;

// 整合Junit框架
@RunWith(SpringJUnit4ClassRunner.class)

// 整合Spring配置类和Mybatis配置类

@ContextConfiguration(classes = {SpringConfig.class, MyBatisConfig.class})
public class Demo01 {

    @Resource
    private UserService userService;


    @Resource
    private AccountService accountService;

    @Test
    public void test02(){
        accountService.change(1, 2, 2.0);
        System.out.println("转账完毕");
    }



    @Test
    public void test01(){
        // 查询所有
        List<User> all = userService.findAll();
        for (User user : all) {
            System.out.println(user);
        }
    }
}
